<?php

class jsonActions extends sfActions {

    public function executeAutocomplete_advertiser(sfWebRequest $request){
        $advertiser = $request->getParameter('advertiser');

        $request->setRequestFormat('json');
        $advertisers = array();

        $c = new Criteria();
        $c->add(AdvertiserPeer::NOMBRE, "%".$advertiser."%", Criteria::LIKE);
        $c->addAscendingOrderByColumn(AdvertiserPeer::NOMBRE);
        $c->setDistinct();
        $c->setLimit(15);
        $advertisers = AdvertiserPeer::doSelect($c);

        $this->advertisers = $advertisers;
    }

    public function executeAutocomplete_item(sfWebRequest $request){
        $item = $request->getParameter('item');

        $request->setRequestFormat('json');
        $items = array();

        $c = new Criteria();
        $c->add(RelatedItemPeer::NOMBRE_RUBRO_RESULTADO, "%".$item."%", Criteria::LIKE);
        $c->addAscendingOrderByColumn(RelatedItemPeer::NOMBRE_RUBRO_RESULTADO);
        $c->setDistinct();
        $c->setLimit(15);
        $items = RelatedItemPeer::doSelect($c);

        $this->items = $items;
    }

}